---
--类名: CaptainObtainView.lua
--创建日期: 2018-11-02
--创建人: 宋建邦
--功能描述: view
--修改内容:

local CaptainObtainView = class("CaptainObtainView", app.mvc.ViewBase)
CaptainObtainView.VIEW_ROOT_RES = Res.MountGetScene

function CaptainObtainView:init()
    self:setBackGroundColorType(0)
    self:setNodeEventEnabled(true)

    display.setCascadeOpacityEnabled(self._root, true)
    self._ui.Button_ok:addClickEventListener(function()
        self:closeView()
    end)

    local con = self._ui["Panel/Panel_content"]
    self._tltText = con:getChildByName("tlt")

    self._listView = con:getChildByName("ListView")
    self._itemModel = self._listView:getItem(0)
    self._itemModel:retain()
    self._listView:removeAllItems()


    local panelBar = con:getChildByName("Panel_bar")
    -- self._bar = panelBar:getChildByName("LoadingBar")
    -- self._numText = panelBar:getChildByName("num")
    -- self._panelBar = panelBar
    panelBar:hide()
end

function CaptainObtainView:onExit()
end

function CaptainObtainView:refresh(data, cname)
    if cname then
        self._tltText:setString(L("captain_collectors_obtain"))
        self._ui.tlt:setString(L(cname))
    end
    if data and #data > 0 then
        for i,v in ipairs(data) do
            local item = self._itemModel:clone()
            self._listView:pushBackCustomItem(item)
            -- item:setTag(v[1])
            item:getChildByName("name"):setString(L(v[2]))
            item:setPressedActionEnabled(false)
            item:addClickEventListener(function(render)
                app:sendMsg("CaptainController", "gotoFeature", {feature = v[1], param = v[3]})
                self:closeView()
                --[[VIEW_ROOT_RESapp:sendMsg("CaptainController", "closeCollectView")
                app:sendMsg("CaptainController", "closeCaptainView")
                UIHandler:handleMessage({id= checknumber(v[1]), mode="open"})--]]
            end)
        end
    else
        self._listView:removeAllItems()
    end
end


return CaptainObtainView